<template>
  <aside>
    <ul>
      <li
        v-for="(item, index) in menu"
        :key="index"
        :class="[selectIndex == index ? 'active' : '']"
        @click="changeUrl(item.url, index)"
        :title="item.title"
      >
        <i class="iconfont" :class="item.icon"></i>
        <div class="aside-title">
          {{ item.name}}
          <!-- <el-badge  v-show="item.name == '人员审核' && getAudit > 0" :value="getAudit" :max="99" class="add-star"></el-badge> -->
        </div>
      </li>
    </ul>
  </aside>
</template>
<script>
import base from "@/assets/js/base";
export default {
  name: "asideBar",
  data() {
    return {
      selectIndex: 0,
      menu: [],
    };
  },
  computed: {
    getAudit() {
      return this.$store.state.isAudit;
    },
  },
  methods: {
    changeUrl(name, index) {
      this.selectIndex = index;
      this.$router.push(name);
      sessionStorage.setItem("selectIndex", index);
    },
  },

  created() {
    this.selectIndex = sessionStorage.getItem("selectIndex");
    if (sessionStorage.getItem("KEY") == "A") {
      this.menu = base.getMenu("admin");
    } else if (sessionStorage.getItem("KEY") == "C") {
      this.menu = base.getMenu("check");
    } else if (sessionStorage.getItem("KEY") == "O") {
      this.menu = base.getMenu("operator");
    } else if (sessionStorage.getItem("KEY") == "company") {
      this.menu = base.getMenu("company");
    } else if (sessionStorage.getItem("KEY") == "personage") {
      this.menu = base.getMenu("user");
    } else if (sessionStorage.getItem("KEY") == "F") {
      this.menu = base.getMenu("finance");
    }
  },
};
</script>
<style scoped>
aside {
  float: left;
  min-width: 100px;
  width: 10%;
  box-sizing: border-box;
  padding-right: 30px;
}
aside li {
  padding: 10px 0;
  font-size: 14px;
  color: #333;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
}
aside .active {
  color: #13cb6e;
}
aside li .aside-title {
  position: relative;
  display: inline-block;
  /* width: 56px; */
  text-align: left;
}
.aside-title .add-star {
  position: absolute;
  top: -12px;
}
</style>
